<?php 
$user=$session->read('User');
$companyid=$session->read("companyid");
$isflag=$action->checkPermissions($user,$companyid);
?>
<div class="right_side_operate_area">
	<div class="right_side_title left">
    	<h2>
		<?php 
		$companyname=$session->read("companyname");
		echo $html->link($companyname,"/companys/showinfosummary/".$companyid);
		?>
    	</h2>
    	<div class='clear'></div>
    </div>
    <div class="right back_btn"><?php echo $html->link("返回","/companys/patents/".$_SESSION['companyid'])?></div>
    <div class="clear"></div>
</div>
<div class="right_side_scollbar">
    <div class="detail_info_panel">
		<div class="details_item_line">
			<div class="details_item">
                <div class="form_left_title left"><?php echo "专利名";?>：</div>
                <div class="form_right_input left"><?php echo $patent['CompanyPatent']['pname'] ;?></div>
            </div><div class="details_item">
                <div class="form_left_title left"><?php echo "专利类型";?>：</div>
                <div class="form_right_input left"><?php echo $patent['type_id']['value'] ;?></div>
            </div>
     	</div>
     	<div class="details_item_line">
            <div class="details_item">
                <div class="form_left_title left"><?php echo "专利状态/时间" ; ?>：</div>
                <div class="form_right_input left">
                <?php 
                $status=$patent["CompanyPatent"]["state"];
				$apply_time=$patent["CompanyPatent"]["apply_time"];
				$accept_time=$patent["CompanyPatent"]["accept_time"];
				$authorize_time=$patent["CompanyPatent"]["authorize_time"];
				$buy_time=$patent["CompanyPatent"]["buy_time"];
                echo $str->getstaus($status).'/'.$str->getstaustime($status, $apply_time, $accept_time, $authorize_time,$buy_time);
                ?>
                </div>
            </div>
            <div class="details_item">
                <div class="form_left_title left"><?php echo "创建时间";?>：</div>
                <div class="form_right_input left">
                <?php 
					$created=$patent["CompanyPatent"]["created"];
					$created=date("Y-m-d",strtotime($created));
                	echo $created;
                ?>
                </div>
            </div>
        </div>
        <div class="details_item_line">
			<div class="details_item">
			    <div class="form_left_title left"><?php echo "专利所属" ;?>：</div>
			    <div class="form_right_input left">
			    <?php 
				    $select=$patent["CompanyPatent"]["to"];
				   	echo $str->getpatentto($select);
				   	$person_name=$patent['CompanyPatent']['person_name'];
				   	if($select=="1" && !empty($person_name)){
				   		echo "(".$person_name.")";
				   	}
			    ?>
			    </div>
			</div>
			<div class="details_item">
			    <div class="form_left_title left"><?php echo "所属地址" ;?>：</div>
			    <div class="form_right_input left">
			    <?php echo $patent["CompanyPatent"]['address'];?>
			    </div>
			</div>
		</div>
		
		<?php if($status!='3'){ ?>
		<div class="details_item_line">
			<div class="details_item">
			    <div class="form_left_title left"><?php echo "专利进展" ;?>：</div>
			    <div class="form_right_input left">
			    	<?php 
			    		$Patentstatus=classregistry::init('Constant')->Patentstatus;
			    		if($apply_time){
			    			echo $Patentstatus[0]."时间&nbsp;".$str->formattime($apply_time)."&nbsp;&nbsp;";
			    		}
			    		if($accept_time){
			    			echo $Patentstatus[1]."时间&nbsp;".$str->formattime($accept_time)."&nbsp;&nbsp;";
			    		}
			    		if($authorize_time){
			    			echo $Patentstatus[2]."时间&nbsp;".$str->formattime($authorize_time);
			    		}
			    	?>
			    </div>
			</div>
		</div>
		<?php } ?>
		
        <div class="details_item_line">  
            <div class="details_item">
                <div class="form_left_title left"><?php echo "专利描述" ;?>：</div>
                <div class="form_right_input left">
                		<?php
		           					$content = $str->formatTextarea($patent['CompanyPatent']['content'] );
		           					echo $content;
		             	?>
                </div>
            </div>
        </div> 
        <div class="details_item_line">  
            <div class="details_item">
                <div class="form_left_title left"><?php echo "附件" ;?>：</div>
                <div class="left">
                	<div class="file_category_list">
		        		<div id="filelist0" class="file_lists">
		        			<?php $dan="'";
			                	if($attachments){?>
		        			<ul class="picture_attach">
		        				<?php
			                	foreach($attachments as $attachment){
			                			$fname=$attachment["file_name"];
			                			$fpath=$attachment["file_path"];
			                			$fid=$attachment["id"];
			                			$createdtime=date("Y-m-d",strtotime($attachment["created"]));
			                			$isimg=$str->checkimg($fname);
			                			if($isimg){
											echo "<li>";
											echo '<div class="picture_info">';
											echo "<span>".$fname."</span>";
											echo "<span class='source_upload_date'>".$createdtime.$html->link("下载",'/projects/download/'.$attachment["id"],null)."</span>";
											echo "</div>";
											if($isflag){
												echo '<span class="source_upload_delete"><a title="删除" onclick="delfile(this,'.$dan.$attachment["id"].$dan.',0)" href="javascript:void(0)"></a></span>';
											}
											$img=$html->image("/".$fpath);
											echo "<span>".$html->link($img,'javascript:void(0);',array('onclick'=>"openimg(".$dan."f".$fid.$dan.")",'escape' => false))."</span>";
											echo "<div style='display:none' id='f".$fid."' title='".$fname."'>".$img."</div>";
											
											echo "</li>";
										}
									}
			                	?>
		        				<div class="clear"></div>
		        			</ul>
		        			<ul class="file_attach">
			                	<?php
			                	foreach($attachments as $attachment){
			                			$fname=$attachment["file_name"];
			                			$isimg=$str->checkimg($fname);
			                			if(!$isimg){
											echo "<li>";
											echo "<span>".$html->link($fname,'/projects/download/'.$attachment["id"],null)."</span>";
											echo "<span class='source_upload_date'>".date("Y-m-d",strtotime($attachment["created"]))."</span>";
											if($isflag){
												echo '<span class="source_upload_delete"><a title="删除" onclick="delfile(this,'.$dan.$attachment["id"].$dan.',0)" href="javascript:void(0)"></a></span>';
											}
											echo "</li>";
										}
									}
			                	?>
			                	<div class="clear"></div>
			                </ul>
			                <?php 
			                	}else{
									echo '<div class="form_right_input left">暂无文件</div>';
								}
			                ?>
		                </div>
		             </div>
				</div>
            </div>
        </div>
    </div>
</div>
<?php echo $this->element('delfileconfirm',array("title"=>"删除提示","message"=>"你确定要删除吗？")) ?>    